import java.util.Scanner;

public class Java1_5 {

    public static int sum(int a,int b) {
        return a+b;
    }

    public static int sum(int a,int b,int c) {
        return a+b+c;
    }

    public static double sum(double d1,double d2) {
        return d1+d2;
    }

    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        int n = sum(a,b);
        System.out.println(n);

        double d1 = 1.3;
        double d2 = 2.4;
        double m = sum(d1,d2);
        System.out.println(m);

        System.out.println(sum(1, 2, 3));


    }

    public static void swap(int a,int b) {
        int tmp = a;
        a = b;
        b = tmp;
        System.out.println(a);
        System.out.println(b);
    }

    public static void main49(String[] args) {
        int a = 10;
        int b = 20;
        swap(a,b);
        System.out.println(a);
        System.out.println(b);
    }

    public static int facNum(int num) {
        //求某个数字的阶乘和
        int sum = 0;
        for (int j = 1; j <= num; j++) {
            //int ret = fac(j);
            sum += fac(j);
        }
        //System.out.println(sum);
        return sum;
    }

    public static int fac(int n) {
        //求某个数字的阶乘
        int ret = 1;
        for (int i = 1; i <= n; i++) {
            ret *= i;
        }
        return ret;
    }

    public static void main48(String[] args) {
        //int ret = facNum(5);
        //System.out.println(ret);
        System.out.println(facNum(5));
    }

    public static int add1(int a,int b) {
        return a+b;
    }

    public static void main47(String[] args) {
        int a = 10;
        int b = 20;
        int sum = add1(1,2);
        System.out.println(sum);
        int ret = add1(a,b);
        System.out.println(ret);
    }

    public static boolean isLeapYear(int year) {
        //int year = 1900;
        if((0 == year % 4 && 0 != year % 100) || 0 == year % 400){
            //System.out.println(year+"年是闰年");
            return true;
        }else{
            //System.out.println(year+"年不是闰年");
            return false;
        }
    }

    public static void main46(String[] args) {
        //判断是否为闰年
        boolean flg = isLeapYear(2022);//传参
        System.out.println(flg);
    }

    public static int add(int a,int b) {
        return a+b;
    }

    public static void main45(String[] args) {
        int a = 10;
        int b = 20;
        int ret = add(a,b);
        System.out.println(ret);
        ret = add(30,50);
        System.out.println(ret);
    }

    public static void main44(String[] args) {
        //使用 Scanner 循环读取 N 个数字，并求取其平均值
        int sum = 0;
        int num = 0;
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            sum += n;
            num++;
        }
        System.out.println(sum);
        System.out.println(sum/num);//用CTRL+d结束循环
    }

    public static void main43(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        double a = scanner.nextDouble();
        float b = scanner.nextFloat();
        String c = scanner.nextLine();
        scanner.close();//调用关闭方法
    }

    public static void main42(String[] args) {
        System.out.println("hello world");
        int x = 10;
        System.out.printf("x = %d\n", x);
    }

    public static void main41(String[] args) {
        //计算 1! + 2! + 3! + 4! + 5!
        int sum = 0;
        for (int i = 1; i <= 5; i++) {
            int s = 1;
            for (int j = 1; j <= i ; j++) {
                s *= j;
            }
            sum += s;
        }
        System.out.println(sum);
    }

    public static void main40(String[] args) {
        //计算5的阶乘
        int s = 1;
        for (int i = 1; i <= 5; i++) {
            s *= i;
        }
        System.out.println(s);
    }

    public static void main39(String[] args) {
        //计算1-100的和
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            sum += i;
        }
        System.out.println(sum);
    }

    public static void main38(String[] args) {
        //打印1-10数字
        for (int i = 1; i <= 10; i++) {
            System.out.println(i);
        }
    }

    public static void main37(String[] args) {
        //找到 100 - 200 中所有 3 的倍数
        int num = 100;
        while (num <= 200) {
            if (num % 3 != 0) {
                num++;
                continue;
            }
            System.out.println(num);
            num++;
        }
    }

    public static void main36(String[] args) {
        //找到 100 - 200 中第一个 3 的倍数
        int num = 100;
        while (num <= 200) {
            if (num % 3 == 0) {
                System.out.println(num);
                break;
            }
            num++;
        }
    }

    public static void main35(String[] args) {
        //计算 1! + 2! + 3! + 4! + 5!
        int a = 1;
        int sum = 0;
        while (a <= 5) {
            int s = 1;
            int t = 1;
            while (t <= a) {
                s *= t;
                t++;
            }
            sum += s;
            a++;
        }
        System.out.println(sum);
    }

    public static void main34(String[] args) {
        //计算5的阶乘
        int a = 1;
        int s = 1;
        while (a <= 5) {
            s *= a;
            a++;
        }
        System.out.println(s);
    }

    public static void main33(String[] args) {
        //计算1-100的和
        int a = 1;
        int sum = 0;
        while (a <= 100) {
            sum += a;
            a++;
        }
        System.out.println(sum);
    }

    public static void main32(String[] args) {
        //打印1-10数字
        int a = 1;
        while (a <= 10) {
            System.out.println(a);
            a++;
        }
    }

    public static void main31(String[] args) {
        int day = 1;
        switch(day) {
            case 1:
                System.out.println("星期一");
                break;
            case 2:
                System.out.println("星期二");
                break;
            case 3:
                System.out.println("星期三");
                break;
            case 4:
                System.out.println("星期四");
                break;
            case 5:
                System.out.println("星期五");
                break;
            case 6:
                System.out.println("星期六");
                break;
            case 7:
                System.out.println("星期日");
                break;
            default:
                System.out.println("输入有误");
                break;
        }
    }

    public static void main30(String[] args) {
        //判断是否为闰年
        int n = 2001;
        if (n % 4 == 0 && n % 100 == 0 && n % 400 == 0) {
            System.out.println("闰年");
        }else {
            System.out.println("不是闰年");
        }
    }

    public static void main29(String[] args) {
        //判断一个数字是正数，负数，还是0
        int a = 0;
        if (a > 0) {
            System.out.println("正数");
        }else if (a < 0) {
            System.out.println("负数");
        }else {
            System.out.println("0");
        }
    }

    public static void main28(String[] args) {
        //判断一个数字是奇数还是偶数
        int a = 1;
        if (a % 2 == 0) {
            System.out.println("偶数");
        }else {
            System.out.println("奇数");
        }
    }

    public static void main27(String[] args) {
        int a = 70;
        if (a >= 80) {
            System.out.println("棒棒糖");
        }else {
            System.out.println("作业");
        }
    }

    public static void main26(String[] args) {
        System.out.println("111");
        System.out.println("222");
        System.out.println("333");
    }

    public static void main25(String[] args) {
        int a = 10;
        int b = 20;
        int max = a > b ? a : b;
        System.out.println(max);
    }

    public static void main24(String[] args) {
        int a = 0x1;
        int b = 0x2;
        System.out.printf("%x\n",a^b);
    }

    public static void main23(String[] args) {
        int a = 0xf;
        System.out.printf("%x\n",~a);
    }

    public static void main22(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println(a | b);
    }

    public static void main21(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println(a & b);
    }

    public static void main20(String[] args) {
        System.out.println(1+0.2);
    }

    public static void main19(String[] args) {
        System.out.println(11.5%2.0 );
    }

    public static void main18(String[] args) {
        int a = 3;
        int b = 0;
        System.out.println(a/b);
        System.out.println(a%b);
    }

    public static void main17(String[] args) {
        int a = 3;
        int b = 2;
        System.out.println(a/b);
        double d = a*1.0/b;
        System.out.println(d);
    }

    public static void main16(String[] args) {
        String str = "100";
        int num = Integer.parseInt(str);
        System.out.println(num);
    }

    public static void main15(String[] args) {
        int num = 10;
        String str = num + "";
        String str2 = String.valueOf(num);
        System.out.println(str);
        System.out.println(str2);
    }

    public static void main14(String[] args) {
        String a = "Hello";
        String b = "World";
        System.out.println(a+b);
    }

    public static void main13(String[] args) {
        byte a = 11;
        byte b = 10;
        byte c = 0;
        //c = a + b;
        byte d = (byte)(a+b);
        System.out.println(a+b);
    }

    public static void main12(String[] args) {
        int a = 10;
        long b = 20;
        //int c = a + b;
        long d = a + b;
    }

    public static void main11(String[] args) {
        int a = 10;
        long b = 100L;
        b = a;//隐式类型转换
        a = (int) b;//显式类型转换
        System.out.println(a);
        float c = 3.14f;
        double d = 13.45;
        //d = c;
        c = (float) d;
        System.out.println(c);
        //a = d;//类型不兼容
        a = (int) d;
        System.out.println(a);
        byte b1 = 100;
        byte b2 = (byte) 257;
        System.out.println(b2);
        boolean flg = true;
        //a = flg;
        //flg = a;编译失败 类型不兼容
    }

    public static void main10(String[] args) {
        int a = 10;
        long b = 100L;
        b = a;
        //a = b;
        float c = 3.14f;
        double d = 33.4;
        //c = d;
        d = c;
    }

    public static void main9(String[] args) {
        boolean a = true;
        boolean b = false;
    }

    public static void main8(String[] args) {
        char a = 'a';
        char A = 'A';
        char b = '帅';
        System.out.println(b);
    }

    public static void main7(String[] args) {
        double num = 1.1;
        System.out.println(num*num);
    }

    public static void main6(String[] args) {
        double a = 1.0;
        double b = 2.0;
        System.out.println(a/b);
    }

    public static void main5(String[] args) {
        int a = 1;
        int b = 2;
        System.out.println(a/b);
    }

    public static void main4(String[] args) {
        byte a = 12;
        System.out.println(Byte.MAX_VALUE);
        System.out.println(Byte.MIN_VALUE);
    }

    public static void main3(String[] args) {
        short a = 10;
        System.out.println(Short.MAX_VALUE);
        System.out.println(Short.MIN_VALUE);
    }

    public static void main2(String[] args) {
        int a = 10;
        System.out.println(Integer.MIN_VALUE);
        System.out.println(Integer.MAX_VALUE);
        long b = 13L;
        System.out.println(Long.MAX_VALUE);
        System.out.println(Long.MIN_VALUE);
    }

    public static void main1(String[] args) {
        int a = 10;
        double b = 3.14;
        char c = 'a';
        float d = 1.2f;
        boolean e = true;
        int a1 = 10,a2 = 20,a3 = 30;
        System.out.println("HI");
        System.out.println("HelloWorld");
    }

}
